library('car')
## Loading required package: carData
library("ggplot2")

Question 1

Given these results of a regression: Coeff se t P Intercept 1.609 1.799 0.894 0.135 P/A ratio 0.006 0.004 1.654 0.073 Scorpions -0.746 0.060 -12.387 <0.001

The r2 from the regression was 0.73.

Answers:

  1. Besides normality and homogeneity of variance of the response variable, what other assumptions are important before we can assess each of the tests on regression slopes?

These are all the assumptions of additive models: - Independence of observations and residuals - Effects of predictors combine additively on the response - Relationship between each predictor and the response is linear - Homoscedasticity variance of residuals is constant across the range of fitted values - Residuals should be approximately random - Residuals should be approximately normally distributed - Multicollinearity predictors should not be highly correlated

  1. How would you interpret the regression slope for P/A ratio in this analysis?

I would interpret the regression slope of 0.006 as indicating that the P/A ratio is not highly indicative of the density of spiders, especially given the high, and not significant, p value of 0.073.

  1. Write out the complete regression equation.

log(y) = 1.609 + 0.006(P/A ratio) - 0.746 (Scorpions) + e

  1. What is the r2 value telling us?

An r2 of 0.73 is telling us that the model accounts for 73% of a variance of the response variable (spider density).

  1. How would you interpret these results?

It would be helpful to get the full model results to fully indicate results (F-statistic), however, from the provided information, we can assume that the whole model is significant as the scorpions predict the density of spiders. However, the P/A ratio does not seem to add much information to the model. Biologically, I would interpret these results as indicating that scorpions influence the density of spiders and the P/A ratio doesn’t not have a significant influence.

Question 2

Import data

input_ds <- readxl::read_excel('/Users/kanoalindiwe/Downloads/Projects/playground/R/Quantitative Ecology/Datasets/Paruelo.xlsx')

# Dependent variable
# abundance of C3 plants
C3 <- input_ds$C3
C3log <- log1p(input_ds$C3)

#Independent variables
#Mean Annual Precipitation (MAP)
MAP <- input_ds$MAP

#Mean Annual Temperature (MAT)
MAT <- input_ds$MAT

#MAP that fell in June, July, and August (JJAMAP)
JJAMAP <- input_ds$JJAMAP

# MAP that fell in Dec, Jan, Feb (DJFMAP)
DJFMAP <- input_ds$DJFMAP

# Other
LONG <- input_ds$LONG
LAT <- input_ds$LAT

ds <- data.frame(
  C3 <- input_ds$C3,
  MAP <- input_ds$MAP,
  MAT <- input_ds$MAT,
  JJAMAP <- input_ds$JJAMAP,
  DJFMAP <- input_ds$DJFMAP
)

# Log data
dslog <- data.frame(
  C3 = log1p(input_ds$C3),
  MAP = input_ds$MAP,
  MAT = input_ds$MAT,
  JJAMAP = input_ds$JJAMAP,
  DJFMAP = input_ds$DJFMAP
)

Assumptions

# Model
model <- lm(C3log ~ MAP + MAT + JJAMAP + DJFMAP)

# Normality
vars <- list(MAP = MAP, MAT = MAT, JJAMAP = JJAMAP, DJFMAP = DJFMAP)
hist(C3)

hist(log(C3))

for (var in vars) {
  hist(var)
}

# Independence of observations and residuals
#Pass, assumed to be good in research design

# Effects of predictors combine additively on the response
# Pass, assumed to be good

# Relationship between each predictor and the response is linear
scatterplotMatrix(ds)

scatterplotMatrix(dslog)

# Pass, logging response variable improves relationship to independent variables by increasing the range of values.

# Multicollinearity predictors should not be highly correlated
cor(dslog)
##                  C3         MAP          MAT       JJAMAP       DJFMAP
## C3      1.000000000 -0.05411452 -0.525368579  0.006212391 -0.069539548
## MAP    -0.054114524  1.00000000  0.355090766  0.112259049 -0.404512409
## MAT    -0.525368579  0.35509077  1.000000000 -0.080771307  0.001478037
## JJAMAP  0.006212391  0.11225905 -0.080771307  1.000000000 -0.791540381
## DJFMAP -0.069539548 -0.40451241  0.001478037 -0.791540381  1.000000000
vif(model)
##      MAP      MAT   JJAMAP   DJFMAP 
## 1.607772 1.178565 3.108688 3.715189
# Pass, as correlations under 90% and VIF under 5.

# Homoscedasticity variance of residuals is constant across the range of fitted values
summary(model)
## 
## Call:
## lm(formula = C3log ~ MAP + MAT + JJAMAP + DJFMAP)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.2826 -0.1341 -0.0134  0.1043  0.3879 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  6.166e-01  2.099e-01   2.938  0.00451 ** 
## MAP          8.801e-05  1.162e-04   0.758  0.45124    
## MAT         -2.418e-02  4.597e-03  -5.259 1.58e-06 ***
## JJAMAP      -3.725e-01  3.319e-01  -1.122  0.26560    
## DJFMAP      -3.927e-01  4.071e-01  -0.965  0.33815    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1682 on 68 degrees of freedom
## Multiple R-squared:  0.309,  Adjusted R-squared:  0.2683 
## F-statistic:   7.6 on 4 and 68 DF,  p-value: 4.019e-05
plot(model)

# Pass, residuals dont look drastically skewed to one side on the residuals vs fitted figure.

# Residuals should be approximately normally distributed
# Pass, residuals dont drastically move from the qq norm center line.

Test

# Model
model1 <- lm(C3log ~ MAP + MAT + JJAMAP + DJFMAP)

# Interaction term model
model2 <- lm(C3log ~ MAP + MAT + JJAMAP + DJFMAP + MAP*MAT)

# Check interaction term model
vif(model2)
## there are higher-order terms (interactions) in this model
## consider setting type = 'predictor'; see ?vif
##       MAP       MAT    JJAMAP    DJFMAP   MAP:MAT 
## 10.193316  7.416039  3.337322  3.835522 21.804567
# Fail, VIF too high

# New model with scaling
model3 <- lm(scale(C3log) ~ scale(MAP) + scale(MAT) + scale(JJAMAP) + scale(DJFMAP) + scale(MAP)*scale(MAT))
vif(model3)
## there are higher-order terms (interactions) in this model
## consider setting type = 'predictor'; see ?vif
##            scale(MAP)            scale(MAT)         scale(JJAMAP) 
##              2.131328              1.217147              3.337322 
##         scale(DJFMAP) scale(MAP):scale(MAT) 
##              3.835522              1.889814
# Pass multicolinearity, as VIF is low

# Check impact of variables on model
plot(model3)

influence.measures(model3)
## Influence measures of
##   lm(formula = scale(C3log) ~ scale(MAP) + scale(MAT) + scale(JJAMAP) +      scale(DJFMAP) + scale(MAP) * scale(MAT)) :
## 
##      dfb.1_ dfb.sc.MAP. dfb.s.MAT  dfb.s.JJ  dfb.s.DJ dfb.s.MAP..    dffit
## 1   0.30782   -0.105408   0.22630  0.085549  0.403151   -0.047322  0.84951
## 2   0.16259    0.088110  -0.10495  0.027970  0.099376   -0.027721  0.23307
## 3   0.22507    0.077264  -0.09393 -0.243919 -0.205621   -0.163238  0.35007
## 4   0.21488   -0.036178  -0.04063 -0.070255 -0.158700   -0.055026  0.29946
## 5  -0.03616   -0.005616   0.04018 -0.016200  0.004803   -0.000878 -0.07063
## 6  -0.12946   -0.037201  -0.05633 -0.002999  0.068830    0.064168 -0.20222
## 7  -0.03682    0.035401  -0.05924 -0.054277 -0.016854    0.007921 -0.10712
## 8  -0.09773   -0.139061  -0.03750  0.026882  0.028514   -0.016569 -0.27797
## 9  -0.04646    0.001756  -0.04554 -0.043845 -0.005848    0.007499 -0.09501
## 10 -0.17114    0.133651  -0.00335  0.210660  0.281596    0.038427 -0.33591
## 11 -0.00806    0.001218   0.00989 -0.007752 -0.001633   -0.004164 -0.01878
## 12 -0.07089    0.032270  -0.04497 -0.253200 -0.154485   -0.059201 -0.29504
## 13  0.08255   -0.024322   0.13127 -0.092091 -0.107918   -0.016224  0.19430
## 14  0.07919    0.059025  -0.05328  0.003442 -0.010712   -0.052647  0.11691
## 15 -0.11194   -0.152577  -0.01356 -0.018599  0.005227    0.064162 -0.22044
## 16 -0.01099   -0.002538   0.00140  0.002640  0.007580    0.006086 -0.01600
## 17 -0.12157    0.035193   0.14735 -0.026186 -0.140339   -0.118340 -0.33480
## 18 -0.10312   -0.048059   0.13405 -0.068509 -0.142857   -0.047561 -0.24018
## 19  0.01365   -0.010325   0.02707 -0.004245 -0.013752   -0.013241  0.03407
## 20  0.13795    0.082860  -0.09855 -0.051527 -0.084991   -0.104665  0.22498
## 21 -0.03409   -0.021279  -0.03376 -0.144926 -0.113945   -0.017345 -0.15775
## 22  0.09609   -0.104878  -0.38005  0.567471  0.390713    0.412999  0.77408
## 23 -0.01409    0.008497  -0.02125  0.015986  0.022531    0.008459 -0.03174
## 24  0.16380    0.151762   0.10152 -0.084426 -0.090603   -0.004820  0.38057
## 25 -0.16999    0.081463   0.11658  0.117774  0.009155   -0.068965 -0.33860
## 26 -0.08525   -0.097141  -0.02208 -0.238363 -0.212853   -0.008787 -0.26822
## 27 -0.04938    0.022571  -0.00103  0.025811  0.053247    0.011338 -0.08012
## 28  0.01381   -0.009264   0.00104 -0.015409 -0.007627   -0.000319  0.02580
## 29  0.18105   -0.190253   0.23882 -0.088379 -0.092101   -0.103674  0.37030
## 30 -0.00816    0.015087   0.00931 -0.022123 -0.006844   -0.018904 -0.03825
## 31  0.03184   -0.031843  -0.02709  0.002247 -0.029582    0.020841  0.08015
## 32 -0.04191    0.022434   0.04580  0.059453  0.031551   -0.014777 -0.10159
## 33 -0.09952    0.147401  -0.10815  0.081203  0.116672    0.020421 -0.21350
## 34  0.18272    0.274441  -0.03305 -0.055783  0.103718   -0.161312  0.36392
## 35  0.00183   -0.000864  -0.00136 -0.002260 -0.000919    0.000436  0.00402
## 36 -0.11216    0.084211  -0.07901  0.003360  0.059569    0.014151 -0.17501
## 37 -0.24522   -0.543276   0.14857 -0.299976 -0.504959    0.201587 -0.67721
## 38 -0.07774    0.054620  -0.06367 -0.157926 -0.079756   -0.031901 -0.22065
## 39  0.08956   -0.219862  -0.06848 -0.094344 -0.060327    0.166585  0.32490
## 40 -0.10541    0.258766   0.08060  0.111038  0.071002   -0.196062 -0.38239
## 41 -0.07227    0.262524   0.05964  0.067051  0.057695   -0.205208 -0.34519
## 42 -0.13993   -0.182177   0.03920  0.075475 -0.056782    0.127101 -0.27649
## 43  0.08558    0.087474  -0.00513 -0.041020  0.033229   -0.063488  0.15367
## 44  0.13202   -0.065726  -0.05600 -0.053579 -0.079086    0.018425  0.18977
## 45  0.22039   -0.109724  -0.09349 -0.089446 -0.132026    0.030758  0.31680
## 46  0.06569   -0.032707  -0.02787 -0.026662 -0.039355    0.009169  0.09443
## 47  0.11183   -0.055675  -0.04743 -0.045385 -0.066991    0.015607  0.16075
## 48  0.18276    0.009293  -0.05306 -0.084308 -0.122002   -0.070388  0.23413
## 49  0.26188    0.305494  -0.10551 -0.067256 -0.069514   -0.293158  0.42653
## 50  0.00334   -0.000321   0.02665  0.009843  0.013687    0.056589  0.09062
## 51 -0.00197   -0.005134   0.02335  0.021247  0.017150    0.064879  0.09223
## 52  0.00461    0.007795   0.00470 -0.001774  0.000741    0.012215  0.02962
## 53 -0.00176    0.000151  -0.00385  0.002371  0.001714   -0.002697 -0.00819
## 54  0.00768   -0.027890  -0.00634 -0.007123 -0.006129    0.021801  0.03667
## 55 -0.00492    0.002931   0.00682 -0.002566 -0.007225   -0.007133 -0.01594
## 56 -0.05713   -0.052892   0.08806 -0.077185 -0.138398   -0.033366 -0.18255
## 57  0.14147    0.130963  -0.21804  0.191113  0.342679    0.082615  0.45199
## 58  0.04522   -0.098394  -0.03698 -0.054965 -0.043670    0.070464  0.14900
## 59 -0.14734    0.098842  -0.01106  0.164408  0.081372    0.003400 -0.27522
## 60 -0.10744    0.072076  -0.00806  0.119887  0.059337    0.002479 -0.20069
## 61  0.02457    0.000120   0.07251 -0.000959  0.007399    0.077968  0.16357
## 62 -0.08845    0.008638   0.06811  0.011250 -0.101925   -0.049934 -0.25032
## 63 -0.10582    0.056649   0.15477  0.097379  0.116665   -0.039566 -0.24922
## 64 -0.13339   -0.016909   0.04301  0.147928  0.156468    0.089262 -0.21643
## 65 -0.17290    0.112816  -0.03769  0.255236  0.290463    0.074750 -0.33398
## 66 -0.17757   -0.090804   0.29603 -0.076873  0.024457    0.030593 -0.42359
## 67  0.03246    0.037815  -0.03168  0.013335  0.008539   -0.027272  0.05948
## 68  0.04090   -0.014555   0.06562  0.008374  0.009882   -0.043775  0.09141
## 69 -0.03837   -0.001973  -0.04340 -0.009659 -0.046323    0.030569 -0.10360
## 70  0.06902   -0.009539   0.10870  0.000846  0.021311   -0.091213  0.16227
## 71 -0.11056   -0.099521  -0.03201  0.031521  0.051977    0.068055 -0.18363
## 72 -0.12589   -0.219609   0.06116  0.014211 -0.003039    0.193217 -0.25853
## 73  0.03694   -0.128667  -0.23453  0.219543  0.093873    0.259259  0.42660
##    cov.r   cook.d    hat inf
## 1  0.705 1.11e-01 0.1026   *
## 2  0.951 8.94e-03 0.0280    
## 3  0.944 2.01e-02 0.0518    
## 4  0.856 1.45e-02 0.0282    
## 5  1.136 8.43e-04 0.0454    
## 6  1.053 6.82e-03 0.0428    
## 7  1.233 1.94e-03 0.1193    
## 8  1.115 1.29e-02 0.0874    
## 9  1.144 1.52e-03 0.0567    
## 10 0.972 1.85e-02 0.0547    
## 11 1.148 5.96e-05 0.0474    
## 12 1.187 1.46e-02 0.1267    
## 13 1.138 6.34e-03 0.0770    
## 14 1.115 2.30e-03 0.0442    
## 15 1.116 8.14e-03 0.0726    
## 16 1.138 4.33e-05 0.0390    
## 17 0.960 1.84e-02 0.0516    
## 18 1.040 9.60e-03 0.0489    
## 19 1.316 1.96e-04 0.1687   *
## 20 1.080 8.46e-03 0.0587    
## 21 1.334 4.20e-03 0.1878   *
## 22 0.877 9.55e-02 0.1285    
## 23 1.211 1.70e-04 0.0971    
## 24 0.978 2.38e-02 0.0666    
## 25 0.872 1.86e-02 0.0370    
## 26 1.170 1.21e-02 0.1117    
## 27 1.120 1.08e-03 0.0375    
## 28 1.142 1.13e-04 0.0429    
## 29 1.027 2.26e-02 0.0783    
## 30 1.191 2.48e-04 0.0827    
## 31 1.141 1.09e-03 0.0511    
## 32 1.142 1.74e-03 0.0566    
## 33 1.102 7.64e-03 0.0644    
## 34 1.088 2.20e-02 0.0985    
## 35 1.152 2.73e-06 0.0499    
## 36 1.040 5.11e-03 0.0322    
## 37 1.103 7.52e-02 0.1786    
## 38 1.120 8.16e-03 0.0749    
## 39 1.001 1.74e-02 0.0594    
## 40 0.946 2.39e-02 0.0594    
## 41 1.024 1.97e-02 0.0709    
## 42 1.142 1.28e-02 0.0994    
## 43 1.144 3.98e-03 0.0701    
## 44 0.975 5.95e-03 0.0228    
## 45 0.766 1.59e-02 0.0228    
## 46 1.082 1.50e-03 0.0228    
## 47 1.013 4.30e-03 0.0228    
## 48 0.937 9.00e-03 0.0263    
## 49 1.001 2.99e-02 0.0843    
## 50 1.351 1.39e-03 0.1925   *
## 51 1.458 1.44e-03 0.2511   *
## 52 1.268 1.48e-04 0.1374    
## 53 1.233 1.13e-05 0.1125    
## 54 1.176 2.27e-04 0.0709    
## 55 1.160 4.30e-05 0.0567    
## 56 1.159 5.61e-03 0.0857    
## 57 0.985 3.35e-02 0.0857    
## 58 1.120 3.73e-03 0.0558    
## 59 0.982 1.25e-02 0.0429    
## 60 1.054 6.72e-03 0.0429    
## 61 1.227 4.51e-03 0.1231    
## 62 1.087 1.05e-02 0.0680    
## 63 1.045 1.03e-02 0.0527    
## 64 1.073 7.83e-03 0.0536    
## 65 1.003 1.84e-02 0.0622    
## 66 0.981 2.94e-02 0.0777    
## 67 1.185 5.98e-04 0.0800    
## 68 1.283 1.41e-03 0.1505   *
## 69 1.307 1.81e-03 0.1667   *
## 70 1.397 4.45e-03 0.2230   *
## 71 1.096 5.65e-03 0.0536    
## 72 1.386 1.13e-02 0.2264   *
## 73 1.149 3.03e-02 0.1393
avPlots(model3)

# Pass, fitted vs residuals looks reasonably random, qq of residuals looks normal\; avPlot shows MAT is influential, thats fine.

# model output
summary(model3)
## 
## Call:
## lm(formula = scale(C3log) ~ scale(MAP) + scale(MAT) + scale(JJAMAP) + 
##     scale(DJFMAP) + scale(MAP) * scale(MAT))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.43971 -0.68006 -0.06759  0.52953  1.97384 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -0.002784   0.107341  -0.026    0.979    
## scale(MAP)             0.091286   0.148259   0.616    0.540    
## scale(MAT)            -0.577110   0.112039  -5.151 2.47e-06 ***
## scale(JJAMAP)         -0.195834   0.185522  -1.056    0.295    
## scale(DJFMAP)         -0.184764   0.198888  -0.929    0.356    
## scale(MAP):scale(MAT)  0.007949   0.104914   0.076    0.940    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8617 on 67 degrees of freedom
## Multiple R-squared:  0.309,  Adjusted R-squared:  0.2574 
## F-statistic: 5.993 on 5 and 67 DF,  p-value: 0.000122
# Test effect of centering MAT on model
scatterplot(C3log ~ MAT)

scatterplot(C3log ~ scale(MAT))

# centering data only changes the scale not the data itself

Results

The primary take-away from the model is that mean annual temperature was the only statistically significant variable that influences the abundance of C3 plants throughout the 73 cites. The predictors influenced this model C3log = –0.003 + 0.091×MAP – 0.577×MAT – 0.196×JJAMAP – 0.185×DJFMAP + 0.008×(MAP×MAT) as follows: MAP: slope = 0.091 ± 0.148, t(67) = 0.62, p = 0.54; MAT: slope = –0.577 ± 0.112, t(67) = –5.15, p < 0.001; JJAMAP: slope = –0.196 ± 0.186, t(67) = –1.06, p = 0.30; DJFMAP: slope = –0.185 ± 0.199, t(67) = –0.93, p = 0.36; MAP×MAT: slope = 0.008 ± 0.105, t(67) = 0.08, p = 0.94. The resulting model accounted for 25% of the variability in C3 plat abundance (R2 = 0.309, adjusted R2 = 0.257, F(5, 67) = 5.99, p < 0.001).

Question 3

Import data

input_ds <- readxl::read_excel('/Users/kanoalindiwe/Downloads/Projects/playground/R/Quantitative Ecology/Datasets/dodson.xlsx')

# Response variable
Fish <- input_ds$Fish

# Explanatory variables
Area <- input_ds$Area
PPR <- input_ds$PPR
Cladoc <- input_ds$Cladoc
Copepods <- input_ds$Copepods
# and the interaction between Cladoc and Copepods

# Log Explanatory variables
Fishlog <- log1p(Fish)
Arealog <- log1p(Area)
PPRlog <- log1p(PPR)
Cladoclog <- log1p(Cladoc)
Copepodslog <- log1p(Copepods)

# Other
Lake <- input_ds$Lake

Research question

What influence do the explanatory variables have on species richness of fish?

Statistical method

Multiplicative linear model

Hypothesis statements

H0: None of the predictors (Area, PPR, Cladoc, and Copepods) and the interaction between Cladoc and Copepods have a significant effect in fish abundance. H1: At least one of the predictors (Area, PPR, Cladoc, and Copepods) and/or the interaction between Cladoc and Copepods have a significant effect in fish abundance.

Assumptions

# Preliminary model
model <- lm(Fishlog ~ Arealog + PPRlog + Cladoclog + Copepodslog + Cladoclog*Copepodslog)

# Normality
vars <- list(Area, PPR, Cladoc, Copepods)
for (var in vars) {
  hist(var)
}

# Independence of observations and residuals
# Pass, assumed to be true

# Effects of predictors combine multiplicatively on the response
# Pass, assumed to be true

# Relationship between each predictor and the response is linear
scatterplotMatrix(data.frame(Fish, Area, PPR, Cladoc, Copepods))

scatterplotMatrix(data.frame(Fishlog, Arealog, PPRlog, Cladoclog, Copepodslog))

# Pass, plots generally look linear

# Multicollinearity predictors should not be highly correlated
cor(data.frame(Fishlog, Arealog, PPRlog, Cladoclog, Copepodslog))
##               Fishlog   Arealog    PPRlog Cladoclog Copepodslog
## Fishlog     1.0000000 0.6640788 0.6637047 0.7959995   0.5135353
## Arealog     0.6640788 1.0000000 0.3632907 0.4238550   0.2578050
## PPRlog      0.6637047 0.3632907 1.0000000 0.5804874   0.3313974
## Cladoclog   0.7959995 0.4238550 0.5804874 1.0000000   0.7348999
## Copepodslog 0.5135353 0.2578050 0.3313974 0.7348999   1.0000000
vif(model, type = "predictor")
## GVIFs computed for predictors
##                 GVIF Df GVIF^(1/(2*Df)) Interacts With
## Arealog     1.256840  1        1.121089           --  
## PPRlog      1.700438  1        1.304008           --  
## Cladoclog   1.813147  3        1.104262    Copepodslog
## Copepodslog 1.813147  3        1.104262      Cladoclog
##                            Other Predictors
## Arealog      PPRlog, Cladoclog, Copepodslog
## PPRlog      Arealog, Cladoclog, Copepodslog
## Cladoclog                   Arealog, PPRlog
## Copepodslog                 Arealog, PPRlog
# Pass, correlation is below 90% and GVIF is bellow 5.


# Homoscedasticity variance of residuals is constant across the range of fitted values
plot(model)

# Pass, residuals look approximately random

# Residuals should be approximately normally distributed
shapiro.test(residuals(model))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(model)
## W = 0.96826, p-value = 0.4338
# Pass, shapiro shows normality

Test

# Model
model1 <- lm(Fishlog ~ Arealog + PPRlog + Cladoclog + Copepodslog + Cladoclog*Copepodslog)
summary(model1)
## 
## Call:
## lm(formula = Fishlog ~ Arealog + PPRlog + Cladoclog + Copepodslog + 
##     Cladoclog * Copepodslog)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4242 -0.3383 -0.1487  0.3727  1.0292 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -2.49146    1.75963  -1.416 0.168237    
## Arealog                0.15452    0.04043   3.822 0.000707 ***
## PPRlog                 0.15663    0.08179   1.915 0.066128 .  
## Cladoclog              2.02636    1.13893   1.779 0.086471 .  
## Copepodslog            0.44651    1.09582   0.407 0.686882    
## Cladoclog:Copepodslog -0.39940    0.58819  -0.679 0.502897    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6566 on 27 degrees of freedom
## Multiple R-squared:  0.8061, Adjusted R-squared:  0.7702 
## F-statistic: 22.45 on 5 and 27 DF,  p-value: 7.634e-09
# Model looks good

# Check impact of variables on model
plot(model1)

influence.measures(model1)
## Influence measures of
##   lm(formula = Fishlog ~ Arealog + PPRlog + Cladoclog + Copepodslog +      Cladoclog * Copepodslog) :
## 
##       dfb.1_ dfb.Arlg  dfb.PPRl dfb.Cldc  dfb.Cppd  dfb.Cl.C    dffit cov.r
## 1  -0.119454  0.03744  0.080571  0.22419  9.35e-02 -0.223087  0.49139 0.904
## 2  -0.041334 -0.10930  0.093729  0.01345  7.00e-02 -0.051849 -0.21496 1.605
## 3   1.019121  0.19616  0.076987 -0.92657 -8.08e-01  0.851626  1.21830 1.321
## 4  -0.030423 -0.08874 -0.008052  0.05018  1.85e-02 -0.029061  0.15676 1.245
## 5   0.000892  0.00366 -0.001325 -0.00171  3.86e-05  0.000632 -0.00794 1.344
## 6  -0.013314  0.07360 -0.074428 -0.00870  1.51e-02  0.023971  0.32543 0.870
## 7   0.260566 -0.14084 -0.008773 -0.07320 -4.32e-01  0.257234 -0.67087 2.911
## 8  -0.178726  0.38628  0.197313  0.12636  1.54e-01 -0.178930  0.61706 0.815
## 9   0.150172 -0.26446 -0.126036 -0.15189 -1.22e-01  0.181414 -0.46154 1.181
## 10 -0.089613  0.03334  0.036487  0.04523  7.53e-02 -0.054321 -0.14118 1.571
## 11 -0.042614  0.02547  0.040838  0.05393  3.16e-02 -0.061564 -0.13250 1.579
## 12 -0.014021  0.06231  0.032749  0.01593  1.09e-02 -0.024492  0.10002 1.643
## 13  0.108856 -0.10858  1.363701 -0.92769  4.10e-03  0.621684 -1.99436 0.316
## 14 -0.269236 -0.44165 -0.331900  0.47234  2.06e-01 -0.343515  0.77366 0.750
## 15  0.024515  0.10630 -0.006479 -0.01038 -3.89e-02  0.011599 -0.16868 1.281
## 16  0.429551  0.00209 -0.318836 -0.19529 -3.57e-01  0.243661  0.73988 1.071
## 17 -1.499423  0.94087 -2.119973  1.48810  1.32e+00 -1.286435 -2.68620 0.936
## 18 -0.018876 -0.02667 -0.010676  0.02206  2.67e-02 -0.029698 -0.08331 1.346
## 19  0.066866  0.09678  0.189487 -0.11244 -1.08e-01  0.112741 -0.29491 1.472
## 20 -0.045455 -0.02839  0.000838  0.01937  6.84e-02 -0.039146  0.11148 1.420
## 21 -0.032231 -0.01197 -0.022104  0.03444  4.51e-02 -0.049194 -0.12842 1.297
## 22  0.095517  0.44835 -0.033870  0.01753 -1.97e-01  0.027326 -0.71660 0.811
## 23 -0.028917 -0.08060  0.029926  0.02664  3.15e-02 -0.025845  0.12226 1.299
## 24  0.015461 -0.07782 -0.007777 -0.01001 -2.19e-02  0.031715  0.16894 1.234
## 25  0.006292  0.01809 -0.008575 -0.01011 -3.17e-03  0.007329 -0.02760 1.465
## 26  0.115880 -0.01966 -0.015168 -0.19043 -3.58e-02  0.131554 -0.37765 1.130
## 27 -0.151571  0.08408  0.126399  0.08330  2.03e-01 -0.161931  0.37837 0.926
## 28  0.136608 -0.33673  0.288192 -0.16570 -1.70e-01  0.189297 -0.47340 1.496
## 29  0.096668  0.03892  0.016219 -0.13524 -8.69e-02  0.138785  0.22369 1.373
## 30 -0.089123 -0.28798 -0.236581  0.23690  6.34e-02 -0.174252 -0.51476 1.214
## 31 -0.058199 -0.05454  0.017975  0.07442  5.56e-02 -0.080583 -0.13983 1.513
## 32  0.016765  0.02479 -0.035510 -0.01168 -1.44e-02  0.011867 -0.08271 1.289
## 33 -0.065949 -0.10040  0.060369  0.09614  5.12e-02 -0.087997  0.19641 1.361
##      cook.d    hat inf
## 1  3.88e-02 0.1082    
## 2  7.95e-03 0.2439    
## 3  2.37e-01 0.4094   *
## 4  4.20e-03 0.0679    
## 5  1.09e-05 0.0670    
## 6  1.71e-02 0.0531    
## 7  7.70e-02 0.5981   *
## 8  5.99e-02 0.1283    
## 9  3.54e-02 0.1662    
## 10 3.44e-03 0.2149    
## 11 3.03e-03 0.2172    
## 12 1.73e-03 0.2421    
## 13 5.14e-01 0.3112   *
## 14 9.24e-02 0.1594    
## 15 4.87e-03 0.0862    
## 16 8.84e-02 0.2270    
## 17 1.03e+00 0.5707   *
## 18 1.20e-03 0.0841    
## 19 1.49e-02 0.2098    
## 20 2.14e-03 0.1330    
## 21 2.83e-03 0.0762    
## 22 8.03e-02 0.1567    
## 23 2.57e-03 0.0750    
## 24 4.87e-03 0.0692    
## 25 1.32e-04 0.1446    
## 26 2.37e-02 0.1215    
## 27 2.32e-02 0.0770    
## 28 3.79e-02 0.2698    
## 29 8.56e-03 0.1461    
## 30 4.40e-02 0.1943    
## 31 3.37e-03 0.1873    
## 32 1.18e-03 0.0536    
## 33 6.61e-03 0.1311
avPlots(model1)

# Pass, fitted vs residuals looks reasonably random, qq of residuals looks normal

# Test effect of centering MAT on model
scatterplot(Fishlog ~ Arealog)

scatterplot(scale(Fishlog) ~ scale(Arealog))

# Again, centering data only changes the scale not the data itself

Results

The results show an overall model that accounts for 77% of the variability in fish species richness (R2 = 0.806, adjusted R2 = 0.770, F(5, 27) = 22.45, p < 0.001). The model includes lake size, primary productivity, richness of cepepods, fish, and cladoverans, and the interaction between cladoverans and cepepods (log(Fish) = –2.491 + 0.155×log(Area) + 0.157×log(PPR) + 2.026×log(Cladoc) + 0.447×log(Copepods) – 0.399×(log(Cladoc)×log(Copepods))). Predictors had the following relationships in the model: Arealog: slope = 0.155 ± 0.040, t(27) = 3.82, p < 0.001; PPRlog: slope = 0.157 ± 0.082, t(27) = 1.92, p = 0.066; Cladoclog: slope = 2.026 ± 1.139, t(27) = 1.78, p = 0.086; Copepodslog: slope = 0.447 ± 1.096, t(27) = 0.41, p = 0.687; Cladoclog×Copepodslog: slope = –0.399 ± 0.588, t(27) = –0.68, p = 0.503. From this we can see that log area was the only statistically significant variable in predicting fish species richness.